// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import Client from '@api/efficiency/api/EnergyStatisticApi'

import ListClass from '@api/efficiency/model/EnergyTimeIntervalReq'
import OneClass from '@api/efficiency/model/TimeIntervalPeakValleyReq'

const CLIENT = CORE.grpcCLIENT(Client)

// ============================== 导出远程接口 ============================== //

export default {
  // —————————————————————————————— 列表 —————————————————————————————— //

  validParam(param) {
    return !CORE.isEmpty(param.monitorPointSiteId)
  },
  async getList(param, TIP = '查询时段用能') {
    const DTO = CORE.grpcDTO(ListClass, param)
    const resp = await CORE.grpc(TIP, CLIENT, 'energyTimeInterval', DTO)
    const list = resp.content || []
    return [list.length, list]
  },

  // —————————————————————————————— 单项 —————————————————————————————— //

  async getOne(one, TIP = '查询用能图表') {
    const DTO = CORE.grpcDTO(OneClass, one)
    const resp = await CORE.grpc(TIP, CLIENT, 'timeIntervalPeakValley', DTO)
    return resp
  },
}
